<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;

// 这个文件是执行 docker exec stock_backend php /var/www/html/artisan make:mail Mail; 生成的
class Mail extends Mailable
{
    public $subject;
    public $view;
    public $content;

    use Queueable, SerializesModels;

    /**
     * Create a new message instance.
     */
    public function __construct($param)
    {
        $this->subject = $param['subject'];
        $this->view = $param['view'];
        $this->content = $param['content'];
        //
    }

    /**
     * Get the message envelope.
     */
    public function envelope(): Envelope
    {
        return new Envelope(
            subject: $this->subject,
        );
    }

    /**
     * Get the message content definition.
     */
    public function content(): Content
    {
        $view = 'emails.' . $this->view;
        return new Content(
            view: $view
        );
    }

    /**
     * Get the attachments for the message.
     *
     * @return array<int, \Illuminate\Mail\Mailables\Attachment>
     */
    public function attachments(): array
    {
        return [];
    }
}
